﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace _08_GDI_颜色渐变
{
    public partial class Form1 : Form
    {
        Graphics g;
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            g = this.CreateGraphics();
        }

        private void button1_Click(object sender, EventArgs e)
        {

            LinearGradientBrush myBrush = new LinearGradientBrush(ClientRectangle, Color.Red, Color.Yellow, LinearGradientMode.Vertical);
            g.FillRectangle(myBrush, ClientRectangle);
        }

        private void button2_Click(object sender, PaintEventArgs e)
        {
            Point point1 = new Point(0, 0);
            Point point2 = new Point(0, 100);
            Point point3 = new Point(100, 0);
            SolidBrush myBrush = new SolidBrush(Color.Red);
            Point[] curvePoints = { point1, point2, point3 };
            this.InvokePaint
            //背景绘制
            e.Graphics.FillPolygon(myBrush, curvePoints);
            g.FillRectangle(myBrush, new RectangleF(50, 50, 100, 100));
            g.FillPie(myBrush, new Rectangle(0, 0, 300, 300), 0, 90);

        }
       
        private void button2_Click(object sender, EventArgs e)
        {

        }
    }
}
